package com.bw.common.adapter

import android.view.ViewGroup
import android.widget.ImageView
import androidx.recyclerview.widget.RecyclerView
import com.bw.common.entity.TabEntity
import com.bw.image.GlideImageLoader
import com.youth.banner.adapter.BannerAdapter

/**
 * 首页轮播图适配器
 */
class BannerResAdapter(private val data:List<TabEntity>) : BannerAdapter<TabEntity, BannerResAdapter.BannerViewHolder>(data) {
    inner class BannerViewHolder(val aImageView: ImageView) : RecyclerView.ViewHolder(aImageView)

    override fun onCreateHolder(parent: ViewGroup, viewType: Int): BannerViewHolder {
        val imageView = ImageView(parent.context)
        imageView.layoutParams = ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,ViewGroup.LayoutParams.MATCH_PARENT)
        imageView.scaleType = ImageView.ScaleType.CENTER_CROP
        return BannerViewHolder(imageView)
    }

    override fun onBindView(holder: BannerViewHolder, data: TabEntity, position: Int, size: Int) {
        GlideImageLoader.loadResImage(holder.aImageView.context,data.selImgDrawable,holder.aImageView)
    }

}